<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <title>登录</title>
    <link rel="stylesheet" href="__LAYUI__/css/layui.css" />
    <link rel="stylesheet" href="__STYLE__/login.css" />
</head>
<body>
<div class="login-main">
    <header class="layui-elip">后台登录</header>
    <form class="layui-form" id="loginForm">
        <div class="layui-input-inline">
            <input type="text" name="account" id="l_account" value="admin" required lay-verify="required" placeholder="账号/邮箱/手机号" autocomplete="off"
                   class="layui-input" />
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" id="l_pass" value="123456" required lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input" />
        </div>
        <div class="layui-input-inline login-btn">
            <button type="submit" class="layui-btn">登录</button>
        </div>
        <hr/>
        <!--<div class="layui-input-inline">
        <button type="button" class="layui-btn layui-btn-primary">QQ登录</button>
        </div>
        <div class="layui-input-inline">
        <button type="button" class="layui-btn layui-btn-normal">微信登录</button>
        </div>
        -->
        <p>
            <a href="javascript:;" class="fl">立即注册</a>
            <a href="javascript:;" class="fr">忘记密码？</a>
        </p>
    </form>
</div>
<script src="__LAYUI__/layui.all.js"></script>
<script type="text/javascript">
    var $ = jQuery = window.$ = layui.jquery;
    $('#loginForm').keyup(function (event) {
        if (event.keyCode != 13) return false;
        doLogin();
        event.preventDefault();
        return false;
    });
    $('#loginForm').on('submit', function (event) {
        doLogin();
        event.preventDefault();
        return false;
    });
    $('button[lay-submit]').click(function (event) {
        doLogin();
        event.preventDefault();
        return false;
    });
    //登录操作
    function doLogin() {
        var data = {};
        data.account = $('#l_account').val();
        data.password = $.md5($('#l_pass').val() + app.md5_salt);
        $.post(app.api + 'auth/login', data, function (response) {
            if (response.error == '0') {
                if ($('#remember').attr('checked')) {
                    app.store('remember', 1);
                    app.store('account', data.account);
                    app.store('password', data.password);
                }
                //app.store('token', response.data.token);
                app.store('nickname', data.nickname);
                app.error(response.message);
                app.jump(response.url);
            } else {
                app.error('登录失败:' + response.message);
            }
        },'json');
    }
</script>
<script src="__JS__/jquery.md5.js"></script>
<script src="__PUBLIC__/sys/app.js"></script>
<script>
    window.onload=function(){
        //doLogin();
    }
</script>
</body>
</html>